﻿@model FlexFlow.Model.Organization

@{
    Layout = null;
}
<link href="~/Assets/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<link href="~/Assets/css/tagmanager.css" rel="stylesheet" />
<link href="~/Assets/css/typeahead.css" rel="stylesheet" />
<script src="~/Assets/js/jquery.form.js"></script>
<script src="~/assets/js/jquery.validate.min.js"></script>
<script src="~/Assets/js/typeahead.bundle.js"></script>
<script src="~/Assets/js/flexflow-controls.js"></script>
<script src="~/Assets/js/tagmanager.js"></script>
<script src="~/Assets/js/handlebars.js"></script>

<div class="row">
    <form class="form-horizontal" role="form" id="frmOrgUpdate">
        <input type="text" style="visibility:hidden" value=@Model.Identity id="orgId" name="orgId" />
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="name"> 名称 </label>
            <div class="col-sm-9">
                <input type="text" id="name" name="name" placeholder="名称" value="@Model.Name" class="col-xs-12 col-sm-9">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="type"> 类型 </label>
            <div class="col-sm-9">
                <select class="col-xs-12 col-sm-9" id="type" name="type" data-placeholder="请选择组织机构类型...">
                    <option value="单位">单位</option>
                    <option value="部门">部门</option>
                    <option value="岗位">岗位</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="locked"> 锁定 </label>
            <div class="col-sm-9">
                <label>
                    <input name="locked" class="ace ace-switch ace-switch-4" type="checkbox" checked="@(Model.Locked)">
                    <span class="lbl"></span>
                </label>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">领导</label>
            <div class="col-sm-9">
                <input type="text" autocomplete="off" id="leadersSelector" placeholder="请输入姓名" style="width:9em;" class="input-medium tm-input tm-input-success tm-input-typeahead" data-type="user" data-original-title="" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right">分管领导</label>
            <div class="col-sm-9">
                <input type="text" autocomplete="off" id="chargeLeadersSelector" placeholder="请输入姓名" style="width:9em;" class="input-medium tm-input tm-input-success tm-input-typeahead" data-type="user" data-original-title="" />
            </div>
        </div>
        <div class="col-md-offset-3 col-md-9">
            <button class="btn btn-info" type="submit">
                <i class="icon-ok bigger-110"></i>
                提交
            </button>

            &nbsp; &nbsp; &nbsp;
            <button class="btn" type="reset">
                <i class="icon-undo bigger-110"></i>
                重设
            </button>
        </div>
    </form>
</div>
<script>
    $("#type option[value= '@Model.OrganizationType' ]").attr("selected", true);

    initUserList("#chargeLeadersSelector", '@Model.ChargeLeaders', {
        hiddenTagListName: "chargeLeaders"
    });

    initUserList("#leadersSelector", '@Model.Leaders', {
        hiddenTagListName: "leaders"
    });

    function doUpdateOrg() {
        $("#frmOrgUpdate").ajaxSubmit({
            type: "POST",
            url: "/organizeapi/update",
            success: function (response, statusText) {
                var ref = $('#orgTree').jstree(true);
                ref.refresh();
                bootbox.dialog({
                    message: response.Message,
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-sm btn-primary"
                        }
                    }
                });
            }
        })
    }

    $('#frmOrgUpdate').validate(buildOpt(doUpdateOrg, function () { }));

</script>